
#include "apdu_lib_common.h"

#include "../apdu.core/apdu.h"

#include "../../mk_lib/mk_auto_ptr.h"
#include "../../mk_lib/mk_utility.h"

#include <stdlib.h>
#include <string.h>
#include "../apdu.algo/mac.h"


#define APDU_MAX_DATA_UNIT 1024

#define HS_MAX_DATA_UNIT  0x1400

static device_mgr g_dev_mgr;

static apdu_manager					g_apdu_mgr;

static apdu_dev_manager				g_apdu_dev_mgr;

static apdu_rsa_manager				g_rsa_mgr;
static apdu_ecc_manager				g_ecc_mgr;
static apdu_key_manager				g_key_mgr;
static apdu_cryption_manager		g_cryption_mgr;
static apdu_digest_manager			g_digest_mgr;
static apdu_mac_manager				g_mac_mgr;
static apdu_factory_manager			g_factory_manager;

static apdu_finger_manager			g_finger_manager;


int				g_sw = 0x9000;
int				g_max_transmit_len = APDU_MAX_DATA_UNIT;
int				g_io_delay = 4; //4ms for AS508 under USB3.0

int get_last_sw()
{
	return g_sw;
}

apdu_manager * get_apdu_mgr()
{
	return &g_apdu_mgr;
}

apdu_dev_manager * get_apdu_dev_mgr()
{
	return &g_apdu_dev_mgr;
}

device_mgr * get_dev_mgr()
{
	return &g_dev_mgr;
}

apdu_rsa_manager * get_rsa_mgr()
{
	return &g_rsa_mgr;
}

apdu_ecc_manager * get_ecc_mgr()
{
	return &g_ecc_mgr;
}

apdu_key_manager * get_key_mgr()
{
	return &g_key_mgr;
}

apdu_cryption_manager * get_cryption_mgr()
{
	return &g_cryption_mgr;
}

apdu_digest_manager * get_digest_mgr()
{
	return &g_digest_mgr;
}

apdu_mac_manager * get_mac_mgr()
{
	return &g_mac_mgr;
}

apdu_factory_manager * get_factory_mgr()
{
	return &g_factory_manager;
}

apdu_finger_manager * get_finger_mgr()
{
	return &g_finger_manager;
}

void set_max_transmit_len(int maxTrans)
{
	g_max_transmit_len = maxTrans;
}

int get_max_transmit_len()
{
	return g_max_transmit_len;
}

void set_max_io_delay(int delay)
{
	g_io_delay = delay;
}

int get_max_io_delay()
{
	return g_io_delay;
}
